/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Implementation.SourceCode.DAL;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author mrkingdom75
 */
public class DB_CreateDatabase {
    
    private static final String dropTableVietTat = "drop table if exists viettat;";
    private static final String tableVietTat = "CREATE TABLE viettat(id int,vt_thu_tu int,ten_viet_tat,ten_day_du);";
    private static final String tableMaterial = "create table material(id int, name, short_name, code);";
    private static final String dropTableDienGiai = "drop table if exists diengiai;";
    private static final String tableDienGiai = "CREATE TABLE diengiai(id int,ngay int,thang int,nam int, hoa_don int,dien_giai,so_tien long,thu_tu);";
    
    private static final String test = "CREATE TABLE test(ngay datetime);";
            
    
    public static void main(String[] args) throws Exception {
        Class.forName("org.sqlite.JDBC");
        Connection conn =DriverManager.getConnection("jdbc:sqlite:Database/baocao.db");
        Statement stat = conn.createStatement();
        conn.setAutoCommit(true);
        //stat.executeUpdate(dropTableVietTat);
        stat.executeUpdate(tableMaterial);
        //stat.executeUpdate(tableVietTat);
        
        //stat.executeUpdate(dropTableDienGiai);
        //stat.executeUpdate(tableDienGiai);
        
        //stat.executeUpdate(test);
        //stat.executeUpdate("insert into test (ngay) values ('24/06/2011')");


//        ResultSet rs = stat.executeQuery("select * from diengiai");
////        stat.executeUpdate("delete from diengiai where id<=2193");
//        //1696
////        int retVal = 0;
//        while(rs.next()){
//            System.out.print(rs.getString(1)+"  ||  ");
//            System.out.print(rs.getString(2)+"  ||  ");
//            System.out.print(rs.getString(3)+"  ||  ");
//            System.out.print(rs.getString(4)+"  ||  ");
//            System.out.print(rs.getString(5)+"  ||  ");
//            System.out.print(rs.getString(6)+"  ||  ");
//            System.out.print(rs.getString(7)+"  ||  ");
//            System.out.println(rs.getString(8));
//        }
        //stat.executeUpdate("update diengiai set id=1 where id='%s'");
        //System.out.println("Data Out : "+stat.executeQuery("select max(id) as max from diengiai").getString("max"));
        conn.close();
      }
}
